<?php
/**
 * Created by PhpStorm.
 * User: alice
 * Date: 2015/12/28
 * Time: 12:26
 */

/**
 * Class Involved_CircleLikeModel
 */
class Involved_CircleLikeModel extends BaseModel{

    protected $table = 'circle_like';

    #获取点赞列表
    public function GetLikeList($circle_id)
    {
        return  DB::table($this->table)
            ->select('user.user_id','circle_like.avatar','circle_like.circle_id')
            ->leftJoin('user','user.user_id','=','circle_like.user_id')
            ->where('circle_like.circle_id',$circle_id)
            ->get();
    }

    #获取点赞ID
    public function GetLikeById($circle_id,$user_id)
    {
        return DB::table($this->table)
                ->select('like_id')
                ->where(['circle_id'=>$circle_id,'user_id'=>$user_id])
                ->first();
    }

    public function GetLikeNum($user_id,$circle_id)
    {
        return DB::table($this->table)
            ->where(['user_id'=>$user_id,'circle_id'=>$circle_id])
            ->count();
    }

}